package com.manor.paradise.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.manor.paradise.R
import com.manor.paradise.bean.AuraValueBean
import kotlinx.android.synthetic.main.lyb_item_my_active.view.*
import java.math.BigDecimal

class LybMyActiveDetailsAdapter(data: ArrayList<AuraValueBean.RecordsBean>?, val type: Int = 0)
    : BaseQuickAdapter<AuraValueBean.RecordsBean, BaseViewHolder>(R.layout.lyb_item_my_active, data) {

    override fun convert(helper: BaseViewHolder, item: AuraValueBean.RecordsBean) {
        helper.itemView.sActiveDetailsNameTv.text = item.content
        helper.itemView.sActiveTimeTv.text = item.createTime
        val num = if (item.anima != null) {
            if (item.anima > BigDecimal.ZERO)
                "+" + item.anima.toString()
            else
                "-" + item.anima.toString()
        } else
            ""
        helper.itemView.sActiveDetailsCountTv.text = num
        if (item.anima >= BigDecimal.ZERO) {
            if (type == 0){
                helper.itemView.sActiveTagIv.setImageResource(R.drawable.up_yellow)
            }else{
                helper.itemView.sActiveTagIv.setImageResource(R.drawable.up_green)
            }
        } else {
            helper.itemView.sActiveTagIv.setImageResource(R.drawable.down_gray)
        }
    }
}